import request from '@/utils/request'
const abSettingUrl = process.env.VUE_APP_AB_SETTING

/**
 * http://showdoc.wisetimes.cn:4999/web/#/292?page_id=2640
 * 访问密码: TtHMrdcj
 **/

// 添加ab测试
export function addAbSetting (data) {
  return request({
    // baseURL: abSettingUrl,
    url: abSettingUrl + '/admin/api/v1/abtesting',
    method: 'post',
    data
  })
}
// 获取ab测试详情
export function getAbDetail (abtestid) {
  return request({
    url: abSettingUrl + `/admin/api/v1/abtesting/${abtestid}`,
    method: 'get'
  })
}
// 获取ab列表
export function getAbtestingList (params) {
  return request({
    url: abSettingUrl + '/admin/api/v1/abtesting',
    method: 'get',
    params
  })
}
export function stopAbSetting (ab_test_id) {
  return request({
    // baseURL: abSettingUrl,
    url: abSettingUrl + `/admin/api/v1/abtesting/${ab_test_id}/stop`,
    method: 'post'
  })
}
export function upAbSetting (ab_test_id) {
  return request({
    // baseURL: abSettingUrl,
    url: abSettingUrl + `/admin/api/v1/abtesting/${ab_test_id}/start`,
    method: 'post'
  })
}
export function deleteAbSetting (id) {
  return request({
    url: abSettingUrl + `/admin/api/v1/abtesting/${id}`,
    method: 'delete'
  })
}
// 编辑试验
export function updateAbSetting (id, data) {
  return request({
    url: abSettingUrl + `/admin/api/v1/abtesting/${id}`,
    method: 'put',
    data
  })
}
